/**
 * Write a line on NNET array following the NNET standard
 * 
 * @author root
 * 
 */
public class Writer implements Runnable {

	/**
	 * Pointer of GrayScale class
	 */
	private GrayScale grey;
	/**
	 * image to scan
	 */
	private int[][] immagine;
	/**
	 * number of cell to analyze
	 */
	private int matriceY, blocchiX;

	public Writer(GrayScale grey, int[][] immagine, int matriceY, int blocchiX) {
		this.grey = grey;
		this.immagine = immagine;
		this.matriceY = matriceY;
		this.blocchiX = blocchiX;
	}

	@Override
	public void run() {
		int indice = blocchiX * matriceY;
		for (int matriceX = 0; matriceX < blocchiX; matriceX++) {
			for (int pixelY = 0; pixelY < grey.Y; pixelY++) {
				for (int pixelX = 0; pixelX < grey.X; pixelX++) {
					Double temp = (double) immagine[(matriceX * grey.X) + pixelX][(matriceY * grey.Y) + pixelY];
					temp = temp / 100;
					grey.nnet[indice] += temp + "\t";
				}
			}
			grey.nnet[indice] += "0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0";
			indice++;
		}
		grey.add();
	}

}
